
<?
include_once("./class/mysqldb.inc.php");
$db=new mysqldb();


function insert($arr,$table){
    	if($arr){
    		foreach ($arr as $key=>$value){
    			@$fild[]  = "`".$key."`";
    			@$vals[]  = "'".$value."'";
    		}
    	}
    	$fild = implode($fild,",");
    	$vals = implode($vals,",");
    	return @$sql  =" insert into ".$table."(".$fild.")values(".$vals.")";
    }

 function unsetArray($array,$delarr){
		foreach ($array as $bkey=>$bvalue){
			foreach ($delarr as $key=>$value){
				if($value == $bkey){
				unset($array[$bkey]);		
			    }
		     }
	    }
		return $array;
}
	
function popup($tips,$location='')
{
	if(!empty($location))
		$location = "window.location.href = '$location'";
	else
		$location = "history.back();";

	echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
				<script type=\"text/javascript\">\n
					alert('$tips');\n
					$location;\n
				</script>\n";
	exit();		
}
 
 
 

	function upImage($arr,$str,$uploadfile){
			if($arr['size'] > 1024*1024*2 ){
				popup($str."大小超过2M，不允许上传!");
				exit;
			}
			$type   = explode(".",$arr['name']);
			$name   = date("YmdHis",time()). rand (1,100).".".$type[1];
		
			$typeArray = array(
								"gif" => "image/gif",  
								"jpgc" => "image/jpg",
								"jpeg" => "image/jpeg", 
								"xpng"=>"image/x-png",
								"png"=>"image/png",
		
								);
			if( in_array($arr['type'], $typeArray)){
				$uploadfile = $uploadfile . $name;
				move_uploaded_file ( $arr['tmp_name'], $uploadfile );
				return $name;
				//echo $str."上传成功!","<br>";
			} else {
			    popup($str.$type."类型不支持，添加文件失败!\\n上传图片支持格式为GIF,JPG,PNG,MSWORD文件,且不能大于2M!");
				exit;
			}
	
	}
	
	

if($_POST['action'] == 'add3g'){
      $table  = "hy_b_guestbook";
	  $delarr = array('Submit');
	  
	  $_POST['IDzheng']    = upImage($_FILES['IDzheng'],'身份证正面',"uploadfile/info/");
	  $_POST['IDfan']      = upImage($_FILES['IDfan'],'身份证反面',"uploadfile/info/");

	  $_POST['guest_date'] = time();
	  $post = unsetArray($_POST,$delarr);
	  $sql = insert($post,$table);
	/*  
	  if($post){
	  foreach($post as $key=>$value){
	     echo  "`".$key."` varchar(255) default NULL,  <Br/>";
	  
	  }}
	  */
     $msg = $db->query($sql);

    if($msg){
     	popup('添加成功!');
    }else{
	    popup('添加失败!');
	}
}




?>
<script src="./admin/js/checkSubmit.js"></script>
<script language="javascript">
	 function checkContent(dom){
	if(!check_empty(dom.number,"号码不能为空！")) return false;
	if(!check_isnum(dom.number,"号码只能为数字！")) return false;
	if(!check_isnum(dom.choosingcost,"选号费不能为空！")) return false;
	if(!check_isnum(dom.number,"选号费只能为数字！")) return false;
	
	if(!check_empty(dom.IDzheng,"身份证正面不能为空！")) return false;
	if(!check_empty(dom.IDfan,"身份证反面不能为空！")) return false;
	
		return true;
	 }
	 

</script>
<?
            $SQL="SELECT * FROM `hy_b_3g`  where SpecialCateID = ".$_POST['numbderid'];
			$db->query($SQL);
		   $result = $db->get_data();
		    
			 $SQL3="  select activitymoney from Code_activity  where remarks = ".$_POST['remarks'];
			 $db->query($SQL3);
		   $result2 = $db->get_data();
		  // print_r($result2);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $C['Title'];?></title>
<Link href="../uploadfile/ico/<?php echo $C['ICO'];?>" rel="Shortcut Icon">
<meta name="Keywords" content="<?php echo $C['Keywords'];?>">
<meta name="description" content="<?php echo $C['Description'];?>">
<Meta name="Copyright" Content="<?php echo $C['CopyRight'];?>">
<link href="css/css.css" rel="stylesheet" type="text/css" />
<link charset="utf-8" rel="stylesheet" href="css/alipay.css">
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
</head>
<body id="mainbody">
<?php include_once('header.php');?>
<!--主体布局-->
<div class="main">
  <div class="locahostDIv"> <span>当前位置：<a href="#">首页</a></span> > <a href="#">3G号码套包</a> > <a href="#">选择套餐</a> </div>
  <div class="gehang"></div>
  <div class="bord5">
    <div class="tjdd">
      <div style=" width:228px; margin:0 auto;"><a href="#"><img src="images/tjdd.jpg" /></a></div>
    </div>
    <div class="TL3"> 您选择的号码：<?php echo $result[0]['Serial_number']; ?><br />
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;选号费：<?php echo $result[0]['Fee_code_fee']; ?><br />
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号码品牌：<?php echo $result[0]['Serial_level'];?><br />
      首月资费方式：<?php echo $result[0]['Net_type_code']?> </div>
    <div style="margin:20px;">
    <?
            $SQL="SELECT * FROM `hy_b_3g`  where SpecialCateID = ".$_POST['numbderid'];
			$db->query($SQL);
		   $result = $db->get_data();
		    
			 $SQL3="  select activitymoney from Code_activity  where remarks = ".$_POST['remarks'];
			 $db->query($SQL3);
		   $result2 = $db->get_data();
		  // print_r($result2);

?>
      <form class="registerform" enctype="multipart/form-data" name="form1" id="form1" onSubmit="return checkContent(this);">
        <table width="100%" style="table-layout:fixed;">
          <input name="action" type="hidden" value="add3g" />
          <tr>
            <td class="need" style="width:10px;">*</td>
            <td style="width:110px;">号码：</td>
            <td style="width:305px;"><input name="number" type="hidden" id="number"  value="<?php echo $result[0]['Serial_number']; ?>"/></td>
            <td><div class="Validform_checktip"></div></td>
          </tr>
          <tr>
            <td class="need" style="width:10px;">*</td>
            <td style="width:110px;"> 选号费： </td>
            <td style="width:305px;"><input name="choosingcost" type="hidden" id="choosingcost" value="<?php echo $result[0]['Fee_code_fee']; ?>" /></td>
            <td><div class="Validform_checktip"></div></td>
          </tr>
          <tr>
            <td class="need" style="width:10px;">*</td>
            <td style="width:110px;"> 号码类别： </td>
            <td style="width:305px;"><input name="numbertype" type="hidden" id="numbertype" value="<?php echo $result[0]['Serial_level'];?>"  /></td>
            <td><div class="Validform_checktip"></div></td>
          </tr>
          <tr>
            <td class="need" style="width:10px;">*</td>
            <td style="width:110px;"> 套餐类型： </td>
            <td style="width:305px;"><input name="packagetype" type="hidden" id="packagetype"  value="<?php echo $result[0]['Net_type_code']?>"/></td>
            <td><div class="Validform_checktip"></div></td>
          </tr>
          <tr>
            <td class="need" style="width:10px;">*</td>
            <td style="width:110px;"> 选择套餐： </td>
            <td style="width:305px;"><input name="selectpackages" type="text" id="selectpackages" value="<?php echo $_POST['dinner']?>" /></td>
            <td><div class="Validform_checktip"></div></td>
          </tr>
          <tr>
            <td class="need" style="width:10px;">*</td>
            <td style="width:110px;"> 活动类型： </td>
            <td style="width:305px;"><input name="activitype" type="text" id="activitype"  value="<?php echo $_POST['activity']?>"  /></td>
            <td><div class="Validform_checktip"></div></td>
          </tr>
          <tr>
            <td class="need" style="width:10px;">*</td>
            <td style="width:110px;"> 上传身份证： 
              正面： </td>
            <td style="width:305px;"><input name="IDzheng" type="file" id="IDzheng" /></td>
            <td><div class="Validform_checktip"></div></td>
          </tr>
          <tr>
            <td class="need" style="width:10px;">*</td>
            <td style="width:110px;"> 反面： </td>
            <td style="width:305px;"><input name="IDfan" type="file" id="IDfan" /></td>
            <td><div class="Validform_checktip"></div></td>
          </tr>
          <tr>
            <td class="need" style="width:10px;">*</td>
            <td style="width:110px;"> 证件号码： </td>
            <td style="width:305px;"><input name="ID" type="text" id="ID" /></td>
            <td><div class="Validform_checktip"></div></td>
          </tr>
          <tr>
            <td class="need" style="width:10px;">*</td>
            <td style="width:110px;"> 联系地址： </td>
            <td style="width:305px;"><input name="address" type="text" id="address" /></td>
            <td><div class="Validform_checktip"></div></td>
          </tr>
          <tr>
            <td class="need" style="width:10px;">*</td>
            <td style="width:110px;"> 卡号： </td>
            <td style="width:305px;"><input name="cardnumber" type="text" id="cardnumber" /></td>
            <td><div class="Validform_checktip"></div></td>
          </tr>
          <tr>
            <td class="need" style="width:10px;">*</td>
            <td style="width:110px;"> 应收费用： </td>
            <td style="width:305px;"><input name="costs" type="text" id="costs" value="<?php echo ($result[0]['Fee_code_fee'] )+($result2[0]['activitymoney']);?>" /></td>
            <td><div class="Validform_checktip"></div></td>
          </tr>
          <tr>
            <td class="need" style="width:10px;">*</td>
            <td style="width:110px;"> 两部分费用计算而来：预付话费+活动费用
              
              实收费用： </td>
            <td style="width:305px;"><input name="charged" type="text" id="charged" /></td>
            <td><div class="Validform_checktip"></div></td>
          </tr>
          <tr>
            <td class="need" style="width:10px;">*</td>
            <td style="width:110px;"> 实收费用=应收费用-佣金
         
           <tr>
            <td><div class="Validform_checktip"></div></td>
          </tr>
        </table>
        <div class="ddtj">应收费用:￥100000</div>
        <div class="tjan">
          <div class="tjbl"><input type="submit" name="Submit" value="提交" /></div>
          <div class="qxbl"></div>
        </div>
      </form>
    </div>
  </div>
  <div class="gehang"></div>
  <div style="width:980px;height:100%;overflow:hidden;margin-top:10px"> <img src="images/copy_line.jpg" /><br />
    <br />
    <br />
    <img src="images/copy.jpg" />
    <?php include_once('help.php');?>
    <img src="images/copy_line.jpg" /> </div>
</div>
<div class="clear"></div>
<?php include_once('footer.php');?>
</body>
</html>
